Upload Data

proj_1_data = read_csv("data/Project_1_data.csv") |>
  janitor::clean_names() |>
  mutate(wkly_study_hours = 
           case_match(
             wkly_study_hours,
             "< 5" ~ "< 5 hours",
             "10-May" ~ "5-10 hours",
             "> 10" ~ "> 10 hours"
           ),
         ethnic_group = 
           case_match(
             ethnic_group,
             "group A" ~ "A",
             "group B" ~ "B",
             "group C" ~ "C",
             "group D" ~ "D",
             "group E" ~ "E"
           ),
         nr_siblings = 
           case_match(
             nr_siblings,
             0 ~ "0",
             1 ~ "1",
             2 ~ "2",
             3 ~ "3",
             4 ~ "4+",
             5 ~ "4+",
             6 ~ "4+",
             7 ~ "4+"
           )
         ) 
## Rows: 948 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Gender, EthnicGroup, ParentEduc, LunchType, TestPrep, ParentMarita...
## dbl  (4): NrSiblings, MathScore, ReadingScore, WritingScore
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Filling NA’s. Creating Model Matrix

dummy_col_names = c(
  "gender_male" 
  #, "gender_female"
  
  # , "ethnic_group_A",
  , "ethnic_group_B", "ethnic_group_C" , "ethnic_group_D" , "ethnic_group_E"
  
  # , "parent_educ_some high school"
  , "parent_educ_high school", "parent_educ_some college"
  , "parent_educ_associate's degree", "parent_educ_bachelor's degree"
  , "parent_educ_master's degree" 
  
  
  # , "lunch_type_standard"
  ,"lunch_type_free/reduced"
  
  # , "test_prep_none"
  , "test_prep_completed"
  
  # ,  "parent_marital_status_married"
  , "parent_marital_status_divorced", "parent_marital_status_single"
  , "parent_marital_status_widowed"
  
  # , "practice_sport_never"
  , "practice_sport_sometimes", "practice_sport_regularly"
  
  # , "is_first_child_no"
  , "is_first_child_yes"
  
  # , "transport_means_school_bus"
  ,  "transport_means_private"
  
  # , "nr_siblings_0"
  , "nr_siblings_1", "nr_siblings_2", "nr_siblings_3", "nr_siblings_4+" 
  
  # , "wkly_study_hours_< 5 hours"
  , "wkly_study_hours_> 10 hours", "wkly_study_hours_5-10 hours"
)

score_dummies =
  proj_1_data %>% 
  dplyr::select(-math_score, -reading_score, -writing_score) %>% 
  dummy_cols(ignore_na = TRUE) %>% 
  dplyr::select(all_of(dummy_col_names)) %>% 
  ## fill NA's
  lapply(function(x) ifelse(is.na(x), round(mean(x, na.rm = TRUE), 3), x)) %>% 
  as.data.frame()

Correlation

cor_df = 
  proj_1_data %>%
  dplyr::select(-reading_score, -writing_score) %>% 
  drop_na()

cor_df = 
  model.matrix(object = math_score ~ ., data = cor_df) %>% 
  cor() %>% 
  as.data.frame()
## Warning in cor(.): the standard deviation is zero
cor_df = 
  cor_df %>% 
  mutate(x_name = row.names(cor_df)) %>% 
  filter(x_name != '(Intercept)') %>% 
  dplyr::select(-'(Intercept)') %>% 
  pivot_longer(
    gendermale:`wkly_study_hours5-10 hours`
    , values_to = 'correlation'
    , names_to = 'y_name'
  ) %>% 
  filter(
    substr(x_name, 1, 6) != substr(y_name, 1, 6),
    tolower(x_name) < tolower(y_name)
  )

Getting a histogram of the correlations between the variables.

hist(cor_df$correlation,
     main = "Histogram of Correlations Between Predictors",
     xlab = "Correlation Coefficient")

Getting the top correlations

cor_df %>% 
  arrange(desc(correlation)) %>% 
  mutate(correlation = round(correlation, digits = 3)) %>% 
  head(6) %>% 
  knitr::kable()
x_name y_name correlation
nr_siblings1 parent_educmaster’s degree 0.103
ethnic_groupC parent_marital_statusmarried 0.101
ethnic_groupE nr_siblings3 0.084
nr_siblings4+ parent_educhigh school 0.083
parent_educhigh school test_prepnone 0.081
gendermale parent_educhigh school 0.080

Create Table Summarizing Response Variables

proj_1_data |>
  dplyr::select(math_score, reading_score, writing_score) |>
  pivot_longer(
    cols= everything(),
    names_to = "Test",
    values_to = "Score"
  ) |>
  group_by(Test) |>
  summarize(Mean = round(mean(Score), 2),
            StDev = round(sd(Score), 2),
            Min = min(Score),
            Max = max(Score)) |>
  mutate(Test = case_match(
    Test,
    "math_score" ~ "Math",
    "reading_score" ~ "Reading",
    "writing_score" ~ "Writing"
    )
  ) |>
  knitr::kable()
Test Mean StDev Min Max
Math 65.98 15.53 0 100
Reading 68.84 14.80 17 100
Writing 67.93 15.41 10 100

Single-Variable Categorical Plots

Ethnic Group

proj_1_data |>
  ggplot(aes(x = ethnic_group)) + 
  geom_bar()

Parent Education

proj_1_data |>
  ggplot(aes(x = parent_educ)) + 
  geom_bar()

Lunch Type

proj_1_data |>
  ggplot(aes(x = lunch_type)) + 
  geom_bar()

Test Prep

proj_1_data |>
  ggplot(aes(x = test_prep)) + 
  geom_bar()

Parent Marital Status

proj_1_data |>
  ggplot(aes(x = parent_marital_status)) + 
  geom_bar()

Practicing Sports

proj_1_data |>
  ggplot(aes(x = practice_sport)) + 
  geom_bar()

First Child

proj_1_data |>
  ggplot(aes(x = is_first_child)) + 
  geom_bar()

Number of Siblings

proj_1_data |>
  ggplot(aes(x = nr_siblings)) + 
  geom_bar()

Further EDA

# Histograms for Response Variables

ggplot(data=proj_1_data, aes(math_score)) +
  geom_histogram(color = "black", fill = "white") +
  labs(title = "Histogram of Math Scores",
       x = "Math Score",
       y = "") +
  theme_bw()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(data=proj_1_data, aes(reading_score)) +
  geom_histogram(color = "black", fill = "white") +
  labs(title = "Histogram of Reading Scores",
       x = "Reading Score",
       y = "") +
  theme_bw()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(data=proj_1_data, aes(writing_score)) +
  geom_histogram(color = "black", fill = "white") +
  labs(title = "Histogram of Writing Scores",
       x = "Writing Score",
       y = "") +
  theme_bw()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

# Boxplots for Predictive Variables

ggplot(data=proj_1_data, aes(x=parent_educ,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Parent Education",
       x = "Parent Level of Education",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=parent_educ,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Parent Education",
       x = "Parent Level of Education",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=parent_educ,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Parent Education",
       x = "Parent Level of Education",
       y = "Writng Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=wkly_study_hours,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Study Hours",
       x = "Amount of Hours Studied",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=wkly_study_hours,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Study Hours",
       x = "Amount of Hours Studied",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=wkly_study_hours,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Study Hours",
       x = "Amount of Hours Studied",
       y = "Writing Score") +
  theme_bw()

# Looks strong
ggplot(data=proj_1_data, aes(x=lunch_type,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Lunch Type",
       x = "Lunch Type",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=lunch_type,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Lunch Type",
       x = "Lunch Type",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=lunch_type,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Lunch Type",
       x = "Lunch Type",
       y = "Writing Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=transport_means,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Transportation",
       x = "Transportation Type",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=transport_means,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Transportation",
       x = "Transportation Type",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=transport_means,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Transportation",
       x = "Transportation Type",
       y = "Writing Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=practice_sport,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Sports",
       x = "Sports Participation",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=practice_sport,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Sports",
       x = "Sports Participation",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=practice_sport,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Sports",
       x = "Sports Participation",
       y = "Writing Score") +
  theme_bw()

# Looks strong, look at diff between math and read/write
ggplot(data=proj_1_data, aes(x=gender,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Gender",
       x = "Gender",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=gender,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Gender",
       x = "Gender",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=gender,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Gender",
       x = "Gender",
       y = "Writing Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=ethnic_group,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Ethnic Group",
       x = "Ethnic Group",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=ethnic_group,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Ethnic Group",
       x = "Ethnic Group",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=ethnic_group,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Ethnic Group",
       x = "Ethnic Group",
       y = "Writing Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=parent_marital_status,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Parental Marital Status",
       x = "Parental Marital Status",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=parent_marital_status,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Parental Marital Status",
       x = "Parental Marital Status",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=parent_marital_status,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for Parental Marital Status",
       x = "Parental Marital Status",
       y = "Writing Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=is_first_child,y=math_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for First Child Status",
       x = "First Child Status",
       y = "Math Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=is_first_child,y=reading_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for First Child Status",
       x = "First Child Status",
       y = "Reading Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=is_first_child,y=writing_score)) +
  geom_boxplot() +
  labs(title = "Boxplots for First Child Status",
       x = "First Child Status",
       y = "Writing Score") +
  theme_bw()

ggplot(data=proj_1_data, aes(x=nr_siblings,y=math_score)) + geom_point()

ggplot(data=proj_1_data, aes(x=nr_siblings,y=reading_score)) + geom_point()

ggplot(data=proj_1_data, aes(x=nr_siblings,y=writing_score)) + geom_point()

Modeling

Create Data Frames with only Math, Reading, Writing to Make LM Functions Easier to Write

math_data = score_dummies |> 
  mutate(math_score = proj_1_data$math_score)

reading_data = score_dummies |>
  mutate(reading_score = proj_1_data$reading_score)

writing_data = score_dummies |>
  mutate(writing_score = proj_1_data$writing_score)

All Predictors

Math_All

lm_all_math = lm(math_score ~ ., data = math_data)

summary(lm_all_math)
## 
## Call:
## lm(formula = math_score ~ ., data = math_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -51.644  -8.793   0.423   9.511  32.139 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     55.3291     2.8758  19.240  < 2e-16 ***
## gender_male                      4.9630     0.8757   5.667 1.94e-08 ***
## ethnic_group_B                   1.2761     1.8230   0.700 0.484113    
## ethnic_group_C                   0.9979     1.7119   0.583 0.560079    
## ethnic_group_D                   4.9448     1.7341   2.852 0.004448 ** 
## ethnic_group_E                   9.6236     1.9327   4.979 7.61e-07 ***
## parent_educ_high.school         -0.5837     1.4672  -0.398 0.690828    
## parent_educ_some.college         3.8182     1.4197   2.689 0.007288 ** 
## parent_educ_associate.s.degree   4.6864     1.4237   3.292 0.001033 ** 
## parent_educ_bachelor.s.degree    6.0301     1.6819   3.585 0.000354 ***
## parent_educ_master.s.degree      7.7549     2.1044   3.685 0.000242 ***
## lunch_type_free.reduced        -11.1535     0.9133 -12.212  < 2e-16 ***
## test_prep_completed              5.6331     0.9380   6.006 2.74e-09 ***
## parent_marital_status_divorced  -4.0782     1.2617  -3.232 0.001271 ** 
## parent_marital_status_single    -2.9959     1.0923  -2.743 0.006210 ** 
## parent_marital_status_widowed    0.4294     2.8111   0.153 0.878615    
## practice_sport_sometimes         2.2097     1.4131   1.564 0.118225    
## practice_sport_regularly         3.3317     1.4652   2.274 0.023204 *  
## is_first_child_yes               2.2742     0.9669   2.352 0.018884 *  
## transport_means_private         -0.6603     0.9447  -0.699 0.484751    
## nr_siblings_1                   -1.4314     1.6328  -0.877 0.380910    
## nr_siblings_2                   -1.0911     1.6758  -0.651 0.515145    
## nr_siblings_3                    0.1220     1.6846   0.072 0.942264    
## nr_siblings_4.                  -0.0567     1.7796  -0.032 0.974590    
## wkly_study_hours_..10.hours      3.7385     1.3937   2.682 0.007441 ** 
## wkly_study_hours_5.10.hours      3.0963     1.0352   2.991 0.002854 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.29 on 922 degrees of freedom
## Multiple R-squared:  0.2867, Adjusted R-squared:  0.2674 
## F-statistic: 14.82 on 25 and 922 DF,  p-value: < 2.2e-16
aic_all_math = AIC(lm_all_math)
bic_all_math = BIC(lm_all_math)
adjr2_all_math = lm_all_math |> broom::glance() |> dplyr::select(adj.r.squared)

Reading_All

lm_all_reading = lm(reading_score ~ ., data = reading_data)

summary(lm_all_reading)
## 
## Call:
## lm(formula = reading_score ~ ., data = reading_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -44.457  -8.817   0.626   8.999  30.733 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                    65.88422    2.81201  23.430  < 2e-16 ***
## gender_male                    -7.24074    0.85629  -8.456  < 2e-16 ***
## ethnic_group_B                  0.30125    1.78258   0.169 0.865835    
## ethnic_group_C                  0.71554    1.67395   0.427 0.669146    
## ethnic_group_D                  3.58680    1.69563   2.115 0.034670 *  
## ethnic_group_E                  5.03278    1.88985   2.663 0.007878 ** 
## parent_educ_high.school        -0.92297    1.43463  -0.643 0.520158    
## parent_educ_some.college        2.71841    1.38824   1.958 0.050512 .  
## parent_educ_associate.s.degree  4.32882    1.39213   3.109 0.001932 ** 
## parent_educ_bachelor.s.degree   5.77552    1.64460   3.512 0.000467 ***
## parent_educ_master.s.degree     9.23894    2.05769   4.490 8.03e-06 ***
## lunch_type_free.reduced        -7.52265    0.89309  -8.423  < 2e-16 ***
## test_prep_completed             7.04256    0.91718   7.678 4.10e-14 ***
## parent_marital_status_divorced -4.26487    1.23371  -3.457 0.000571 ***
## parent_marital_status_single   -3.01973    1.06807  -2.827 0.004796 ** 
## parent_marital_status_widowed  -0.02568    2.74877  -0.009 0.992549    
## practice_sport_sometimes        0.95187    1.38176   0.689 0.491068    
## practice_sport_regularly        0.60546    1.43276   0.423 0.672695    
## is_first_child_yes              2.45298    0.94548   2.594 0.009625 ** 
## transport_means_private        -1.33099    0.92376  -1.441 0.149970    
## nr_siblings_1                   0.41222    1.59661   0.258 0.796325    
## nr_siblings_2                  -0.54501    1.63861  -0.333 0.739506    
## nr_siblings_3                   0.26754    1.64727   0.162 0.871017    
## nr_siblings_4.                  0.02602    1.74014   0.015 0.988071    
## wkly_study_hours_..10.hours     2.07394    1.36281   1.522 0.128400    
## wkly_study_hours_5.10.hours     2.20047    1.01222   2.174 0.029966 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13 on 922 degrees of freedom
## Multiple R-squared:  0.249,  Adjusted R-squared:  0.2286 
## F-statistic: 12.23 on 25 and 922 DF,  p-value: < 2.2e-16
aic_all_reading = AIC(lm_all_reading)
bic_all_reading = BIC(lm_all_reading)
adjr2_all_reading = lm_all_reading |> broom::glance() |> dplyr::select(adj.r.squared)

Writing_All

lm_all_writing = lm(writing_score ~ ., data = writing_data)

summary(lm_all_writing)
## 
## Call:
## lm(formula = writing_score ~ ., data = writing_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -49.142  -8.440   1.013   9.108  29.304 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                    62.92757    2.73423  23.015  < 2e-16 ***
## gender_male                    -9.20011    0.83260 -11.050  < 2e-16 ***
## ethnic_group_B                  0.18122    1.73328   0.105 0.916752    
## ethnic_group_C                  0.82358    1.62765   0.506 0.612983    
## ethnic_group_D                  5.54795    1.64874   3.365 0.000797 ***
## ethnic_group_E                  4.60536    1.83758   2.506 0.012375 *  
## parent_educ_high.school        -0.59051    1.39495  -0.423 0.672161    
## parent_educ_some.college        4.38234    1.34985   3.247 0.001210 ** 
## parent_educ_associate.s.degree  5.52787    1.35363   4.084 4.82e-05 ***
## parent_educ_bachelor.s.degree   8.12925    1.59911   5.084 4.48e-07 ***
## parent_educ_master.s.degree    11.99941    2.00078   5.997 2.88e-09 ***
## lunch_type_free.reduced        -8.39668    0.86839  -9.669  < 2e-16 ***
## test_prep_completed             9.75707    0.89181  10.941  < 2e-16 ***
## parent_marital_status_divorced -4.36455    1.19959  -3.638 0.000290 ***
## parent_marital_status_single   -3.33754    1.03853  -3.214 0.001356 ** 
## parent_marital_status_widowed  -0.94821    2.67275  -0.355 0.722843    
## practice_sport_sometimes        2.20441    1.34354   1.641 0.101191    
## practice_sport_regularly        2.92713    1.39313   2.101 0.035902 *  
## is_first_child_yes              2.07416    0.91933   2.256 0.024294 *  
## transport_means_private        -1.15980    0.89821  -1.291 0.196947    
## nr_siblings_1                  -0.62574    1.55246  -0.403 0.686992    
## nr_siblings_2                  -1.20213    1.59329  -0.754 0.450744    
## nr_siblings_3                   0.09188    1.60171   0.057 0.954267    
## nr_siblings_4.                 -0.03309    1.69201  -0.020 0.984400    
## wkly_study_hours_..10.hours     2.03234    1.32512   1.534 0.125445    
## wkly_study_hours_5.10.hours     2.19602    0.98423   2.231 0.025907 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.64 on 922 degrees of freedom
## Multiple R-squared:  0.3453, Adjusted R-squared:  0.3275 
## F-statistic: 19.45 on 25 and 922 DF,  p-value: < 2.2e-16
aic_all_writing = AIC(lm_all_writing)
bic_all_writing = BIC(lm_all_writing)
adjr2_all_writing = lm_all_writing |> broom::glance() |> dplyr::select(adj.r.squared)

Economic Model

Math_Econ

lm_econ_math = lm(math_score ~ parent_educ_high.school + 
                    parent_educ_some.college + 
                    parent_educ_associate.s.degree + 
                    parent_educ_bachelor.s.degree + 
                    parent_educ_master.s.degree + 
                    lunch_type_free.reduced + 
                    test_prep_completed + transport_means_private, 
                  data = math_data)

summary(lm_econ_math)
## 
## Call:
## lm(formula = math_score ~ parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     transport_means_private, data = math_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.868  -9.768   0.369  10.286  36.290 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     64.5844     1.2743  50.682  < 2e-16 ***
## parent_educ_high.school          0.1994     1.5326   0.130 0.896529    
## parent_educ_some.college         4.8978     1.4841   3.300 0.001003 ** 
## parent_educ_associate.s.degree   5.5171     1.4855   3.714 0.000216 ***
## parent_educ_bachelor.s.degree    6.6969     1.7600   3.805 0.000151 ***
## parent_educ_master.s.degree      7.7135     2.1893   3.523 0.000447 ***
## lunch_type_free.reduced        -11.7166     0.9558 -12.258  < 2e-16 ***
## test_prep_completed              6.1758     0.9822   6.288 4.93e-10 ***
## transport_means_private         -0.8511     0.9899  -0.860 0.390107    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.02 on 939 degrees of freedom
## Multiple R-squared:  0.1922, Adjusted R-squared:  0.1853 
## F-statistic: 27.93 on 8 and 939 DF,  p-value: < 2.2e-16
aic_econ_math = AIC(lm_econ_math)
bic_econ_math = BIC(lm_econ_math)
adjr2_econ_math = lm_econ_math |> broom::glance() |> dplyr::select(adj.r.squared)

Reading_Econ

lm_econ_reading = lm(reading_score ~ parent_educ_high.school + 
                    parent_educ_some.college + 
                    parent_educ_associate.s.degree + 
                    parent_educ_bachelor.s.degree + 
                    parent_educ_master.s.degree + 
                    lunch_type_free.reduced + 
                    test_prep_completed + transport_means_private, 
                  data = reading_data)

summary(lm_econ_reading)
## 
## Call:
## lm(formula = reading_score ~ parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     transport_means_private, data = reading_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -41.982  -8.633   0.076   9.479  33.631 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     66.5480     1.2423  53.569  < 2e-16 ***
## parent_educ_high.school         -1.0197     1.4940  -0.683 0.495087    
## parent_educ_some.college         3.5454     1.4468   2.450 0.014448 *  
## parent_educ_associate.s.degree   4.5881     1.4481   3.168 0.001583 ** 
## parent_educ_bachelor.s.degree    6.5793     1.7158   3.835 0.000134 ***
## parent_educ_master.s.degree     10.4679     2.1343   4.905 1.10e-06 ***
## lunch_type_free.reduced         -7.5664     0.9318  -8.120 1.46e-15 ***
## test_prep_completed              7.0994     0.9575   7.414 2.73e-13 ***
## transport_means_private         -1.5933     0.9650  -1.651 0.099059 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.67 on 939 degrees of freedom
## Multiple R-squared:  0.1546, Adjusted R-squared:  0.1474 
## F-statistic: 21.47 on 8 and 939 DF,  p-value: < 2.2e-16
aic_econ_reading = AIC(lm_econ_reading)
bic_econ_reading = BIC(lm_econ_reading)
adjr2_econ_reading = lm_econ_reading |> broom::glance() |> dplyr::select(adj.r.squared)

Writing_Econ

lm_econ_writing = lm(writing_score ~ parent_educ_high.school + 
                    parent_educ_some.college + 
                    parent_educ_associate.s.degree + 
                    parent_educ_bachelor.s.degree + 
                    parent_educ_master.s.degree + 
                    lunch_type_free.reduced + 
                    test_prep_completed + transport_means_private, 
                  data = writing_data)

summary(lm_econ_writing)
## 
## Call:
## lm(formula = writing_score ~ parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     transport_means_private, data = writing_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -45.507  -8.836   0.288   9.665  30.589 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     63.7929     1.2466  51.175  < 2e-16 ***
## parent_educ_high.school         -0.8257     1.4992  -0.551 0.581910    
## parent_educ_some.college         5.2478     1.4518   3.615 0.000317 ***
## parent_educ_associate.s.degree   5.6176     1.4531   3.866 0.000118 ***
## parent_educ_bachelor.s.degree    8.9190     1.7217   5.180 2.71e-07 ***
## parent_educ_master.s.degree     13.0360     2.1416   6.087 1.67e-09 ***
## lunch_type_free.reduced         -8.2864     0.9350  -8.862  < 2e-16 ***
## test_prep_completed              9.7026     0.9608  10.098  < 2e-16 ***
## transport_means_private         -1.3891     0.9683  -1.435 0.151748    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.71 on 939 degrees of freedom
## Multiple R-squared:  0.2152, Adjusted R-squared:  0.2085 
## F-statistic: 32.18 on 8 and 939 DF,  p-value: < 2.2e-16
aic_econ_writing = AIC(lm_econ_writing)
bic_econ_writing = BIC(lm_econ_writing)
adjr2_econ_writing = lm_econ_writing |> broom::glance() |> dplyr::select(adj.r.squared)

Hard Worker Model

Math_HW

lm_hw_math = lm(math_score ~ wkly_study_hours_..10.hours + 
                  wkly_study_hours_5.10.hours + 
                  practice_sport_sometimes + 
                  practice_sport_regularly,
                  data = math_data)

summary(lm_hw_math)
## 
## Call:
## lm(formula = math_score ~ wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours + 
##     practice_sport_sometimes + practice_sport_regularly, data = math_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -68.805  -9.809   0.144  10.511  35.156 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  62.1732     1.6655  37.329  < 2e-16 ***
## wkly_study_hours_..10.hours   4.9610     1.5929   3.114  0.00190 ** 
## wkly_study_hours_5.10.hours   3.6363     1.1888   3.059  0.00229 ** 
## practice_sport_sometimes      0.6823     1.6231   0.420  0.67430    
## practice_sport_regularly      1.6711     1.6820   0.993  0.32073    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.45 on 943 degrees of freedom
## Multiple R-squared:  0.01472,    Adjusted R-squared:  0.01054 
## F-statistic: 3.521 on 4 and 943 DF,  p-value: 0.007313
aic_hw_math = AIC(lm_hw_math)
bic_hw_math = BIC(lm_hw_math)
adjr2_hw_math = lm_hw_math |> broom::glance() |> dplyr::select(adj.r.squared)

Reading_HW

lm_hw_reading = lm(reading_score ~ wkly_study_hours_..10.hours + 
                  wkly_study_hours_5.10.hours + 
                  practice_sport_sometimes + 
                  practice_sport_regularly,
                  data = reading_data)

summary(lm_hw_reading)
## 
## Call:
## lm(formula = reading_score ~ wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours + 
##     practice_sport_sometimes + practice_sport_regularly, data = reading_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -52.350  -9.874   0.869  10.192  32.585 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 67.136978   1.593235  42.139   <2e-16 ***
## wkly_study_hours_..10.hours  2.934960   1.523746   1.926   0.0544 .  
## wkly_study_hours_5.10.hours  2.672754   1.137214   2.350   0.0190 *  
## practice_sport_sometimes    -0.006351   1.552645  -0.004   0.9967    
## practice_sport_regularly    -0.721940   1.608993  -0.449   0.6538    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.78 on 943 degrees of freedom
## Multiple R-squared:  0.007176,   Adjusted R-squared:  0.002965 
## F-statistic: 1.704 on 4 and 943 DF,  p-value: 0.1469
aic_hw_reading = AIC(lm_hw_reading)
bic_hw_reading = BIC(lm_hw_reading)
adjr2_hw_reading = lm_hw_reading |> broom::glance() |> dplyr::select(adj.r.squared)

Writing_HW

lm_hw_writing = lm(writing_score ~ wkly_study_hours_..10.hours + 
                  wkly_study_hours_5.10.hours + 
                  practice_sport_sometimes + 
                  practice_sport_regularly,
                  data = writing_data)

summary(lm_hw_writing)
## 
## Call:
## lm(formula = writing_score ~ wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours + 
##     practice_sport_sometimes + practice_sport_regularly, data = writing_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -59.297 -10.728   0.877  10.680  33.829 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   64.589      1.659  38.936   <2e-16 ***
## wkly_study_hours_..10.hours    3.126      1.587   1.971   0.0491 *  
## wkly_study_hours_5.10.hours    2.731      1.184   2.307   0.0213 *  
## practice_sport_sometimes       1.408      1.617   0.871   0.3840    
## practice_sport_regularly       1.582      1.675   0.945   0.3451    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.39 on 943 degrees of freedom
## Multiple R-squared:  0.007621,   Adjusted R-squared:  0.003412 
## F-statistic:  1.81 on 4 and 943 DF,  p-value: 0.1246
aic_hw_writing = AIC(lm_hw_writing)
bic_hw_writing = BIC(lm_hw_writing)
adjr2_hw_writing = lm_hw_writing |> broom::glance() |> dplyr::select(adj.r.squared)

Demographic Model

Math_Demo

lm_demo_math = lm(math_score ~ gender_male + 
                    ethnic_group_B +
                    ethnic_group_C +
                    ethnic_group_D + 
                    ethnic_group_E, data = math_data)

summary(lm_demo_math)
## 
## Call:
## lm(formula = math_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E, data = math_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -61.526  -9.336   0.474  10.474  35.196 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     58.9959     1.7638  33.449  < 2e-16 ***
## gender_male      5.3481     0.9736   5.493 5.08e-08 ***
## ethnic_group_B   1.8086     2.0254   0.893  0.37211    
## ethnic_group_C   2.5305     1.9007   1.331  0.18340    
## ethnic_group_D   5.7866     1.9317   2.996  0.00281 ** 
## ethnic_group_E  12.2760     2.1425   5.730 1.35e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.92 on 942 degrees of freedom
## Multiple R-squared:  0.08164,    Adjusted R-squared:  0.07677 
## F-statistic: 16.75 on 5 and 942 DF,  p-value: 7.063e-16
aic_demo_math = AIC(lm_demo_math)
bic_demo_math = BIC(lm_demo_math)
adjr2_demo_math = lm_demo_math |> broom::glance() |> dplyr::select(adj.r.squared)

Reading_Demo

lm_demo_reading = lm(reading_score ~ gender_male + 
                    ethnic_group_B +
                    ethnic_group_C +
                    ethnic_group_D + 
                    ethnic_group_E, data = reading_data)

summary(lm_demo_reading)
## 
## Call:
## lm(formula = reading_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E, data = reading_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -54.363  -9.406   0.538  10.512  33.693 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     69.4620     1.6847  41.231  < 2e-16 ***
## gender_male     -7.0560     0.9299  -7.588 7.82e-14 ***
## ethnic_group_B   0.6951     1.9346   0.359 0.719464    
## ethnic_group_C   1.9009     1.8155   1.047 0.295355    
## ethnic_group_D   4.0816     1.8451   2.212 0.027198 *  
## ethnic_group_E   7.0939     2.0465   3.466 0.000551 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.25 on 942 degrees of freedom
## Multiple R-squared:  0.07732,    Adjusted R-squared:  0.07242 
## F-statistic: 15.79 on 5 and 942 DF,  p-value: 5.975e-15
aic_demo_reading = AIC(lm_demo_reading)
bic_demo_reading = BIC(lm_demo_reading)
adjr2_demo_reading = lm_demo_reading |> broom::glance() |> dplyr::select(adj.r.squared)

Writing_Demo

lm_demo_writing = lm(writing_score ~ gender_male + 
                    ethnic_group_B +
                    ethnic_group_C +
                    ethnic_group_D + 
                    ethnic_group_E, data = writing_data)

summary(lm_demo_writing)
## 
## Call:
## lm(formula = writing_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E, data = writing_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -61.073  -9.286   0.703   9.886  32.953 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     68.7161     1.7213  39.922  < 2e-16 ***
## gender_male     -8.9584     0.9501  -9.429  < 2e-16 ***
## ethnic_group_B   0.6785     1.9766   0.343 0.731471    
## ethnic_group_C   2.3567     1.8549   1.271 0.204220    
## ethnic_group_D   6.2968     1.8851   3.340 0.000870 ***
## ethnic_group_E   7.2890     2.0909   3.486 0.000513 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.56 on 942 degrees of freedom
## Multiple R-squared:  0.1119, Adjusted R-squared:  0.1072 
## F-statistic: 23.75 on 5 and 942 DF,  p-value: < 2.2e-16
aic_demo_writing = AIC(lm_demo_writing)
bic_demo_writing = BIC(lm_demo_writing)
adjr2_demo_writing = lm_demo_writing |> broom::glance() |> dplyr::select(adj.r.squared)

Family Structure Model

Math_Fam

lm_fam_math = lm(math_score ~ parent_marital_status_divorced +
                   parent_marital_status_single + 
                   parent_marital_status_widowed + 
                   is_first_child_yes + 
                   nr_siblings_1 + 
                   nr_siblings_2 + 
                   nr_siblings_3 + 
                   nr_siblings_4., 
                 data = math_data)

summary(lm_fam_math)
## 
## Call:
## lm(formula = math_score ~ parent_marital_status_divorced + parent_marital_status_single + 
##     parent_marital_status_widowed + is_first_child_yes + nr_siblings_1 + 
##     nr_siblings_2 + nr_siblings_3 + nr_siblings_4., data = math_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -65.822  -9.958   0.077  10.859  36.096 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     68.2938     1.9139  35.682  < 2e-16 ***
## parent_marital_status_divorced  -4.7421     1.4493  -3.272  0.00111 ** 
## parent_marital_status_single    -3.2902     1.2554  -2.621  0.00891 ** 
## parent_marital_status_widowed    0.3985     3.2269   0.124  0.90173    
## is_first_child_yes               1.9176     1.1098   1.728  0.08435 .  
## nr_siblings_1                   -2.9968     1.8624  -1.609  0.10793    
## nr_siblings_2                   -3.1529     1.9164  -1.645  0.10026    
## nr_siblings_3                   -1.0994     1.9321  -0.569  0.56949    
## nr_siblings_4.                  -1.4586     2.0383  -0.716  0.47441    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.41 on 939 degrees of freedom
## Multiple R-squared:  0.02401,    Adjusted R-squared:  0.01569 
## F-statistic: 2.887 on 8 and 939 DF,  p-value: 0.003506
aic_fam_math = AIC(lm_fam_math)
bic_fam_math = BIC(lm_fam_math)
adjr2_fam_math = lm_fam_math |> broom::glance() |> dplyr::select(adj.r.squared)

Reading_Fam

lm_fam_reading = lm(reading_score ~ parent_marital_status_divorced +
                   parent_marital_status_single + 
                   parent_marital_status_widowed + 
                   is_first_child_yes + 
                   nr_siblings_1 + 
                   nr_siblings_2 + 
                   nr_siblings_3 + 
                   nr_siblings_4., 
                 data = reading_data)

summary(lm_fam_reading)
## 
## Call:
## lm(formula = reading_score ~ parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     is_first_child_yes + nr_siblings_1 + nr_siblings_2 + nr_siblings_3 + 
##     nr_siblings_4., data = reading_data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -52.37 -10.33   0.70  10.30  33.99 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                    67.4458727  1.8249531  36.958  < 2e-16 ***
## parent_marital_status_divorced -4.5553597  1.3818853  -3.296  0.00102 ** 
## parent_marital_status_single   -2.4613325  1.1970580  -2.056  0.04004 *  
## parent_marital_status_widowed   0.0004839  3.0768811   0.000  0.99987    
## is_first_child_yes              3.1206673  1.0582215   2.949  0.00327 ** 
## nr_siblings_1                   1.2360917  1.7758246   0.696  0.48656    
## nr_siblings_2                  -0.2959273  1.8273200  -0.162  0.87138    
## nr_siblings_3                   1.2615396  1.8422516   0.685  0.49365    
## nr_siblings_4.                  0.7630319  1.9435692   0.393  0.69471    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.69 on 939 degrees of freedom
## Multiple R-squared:  0.02287,    Adjusted R-squared:  0.01454 
## F-statistic: 2.747 on 8 and 939 DF,  p-value: 0.005314
aic_fam_reading = AIC(lm_fam_reading)
bic_fam_reading = BIC(lm_fam_reading)
adjr2_fam_reading = lm_fam_reading |> broom::glance() |> dplyr::select(adj.r.squared)

Writing_Fam

lm_fam_writing = lm(writing_score ~ parent_marital_status_divorced +
                   parent_marital_status_single + 
                   parent_marital_status_widowed + 
                   is_first_child_yes + 
                   nr_siblings_1 + 
                   nr_siblings_2 + 
                   nr_siblings_3 + 
                   nr_siblings_4., 
                 data = writing_data)

summary(lm_fam_writing)
## 
## Call:
## lm(formula = writing_score ~ parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     is_first_child_yes + nr_siblings_1 + nr_siblings_2 + nr_siblings_3 + 
##     nr_siblings_4., data = writing_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.822 -10.838   0.763  10.796  34.742 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     67.0068     1.9021  35.228  < 2e-16 ***
## parent_marital_status_divorced  -4.6811     1.4403  -3.250  0.00119 ** 
## parent_marital_status_single    -2.4800     1.2477  -1.988  0.04713 *  
## parent_marital_status_widowed   -0.4628     3.2070  -0.144  0.88529    
## is_first_child_yes               2.9327     1.1030   2.659  0.00797 ** 
## nr_siblings_1                    0.3615     1.8509   0.195  0.84519    
## nr_siblings_2                   -0.7357     1.9046  -0.386  0.69939    
## nr_siblings_3                    1.3629     1.9201   0.710  0.47801    
## nr_siblings_4.                   0.8048     2.0257   0.397  0.69125    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.31 on 939 degrees of freedom
## Multiple R-squared:  0.02126,    Adjusted R-squared:  0.01292 
## F-statistic:  2.55 on 8 and 939 DF,  p-value: 0.009457
aic_fam_writing = AIC(lm_fam_writing)
bic_fam_writing = BIC(lm_fam_writing)
adjr2_fam_writing = lm_fam_writing |> broom::glance() |> dplyr::select(adj.r.squared)

Backwards Selection

Math

lm_step_math = stepAIC(lm_all_math, direction = "backward")
## Start:  AIC=4931.05
## math_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     nr_siblings_3 + nr_siblings_4. + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_4.                  1       0.2 162924 4929.1
## - nr_siblings_3                   1       0.9 162924 4929.1
## - parent_marital_status_widowed   1       4.1 162928 4929.1
## - parent_educ_high.school         1      28.0 162951 4929.2
## - ethnic_group_C                  1      60.0 162983 4929.4
## - nr_siblings_2                   1      74.9 162998 4929.5
## - transport_means_private         1      86.3 163010 4929.6
## - ethnic_group_B                  1      86.6 163010 4929.6
## - nr_siblings_1                   1     135.8 163059 4929.8
## <none>                                        162923 4931.1
## - practice_sport_sometimes        1     432.1 163355 4931.6
## - practice_sport_regularly        1     913.6 163837 4934.4
## - is_first_child_yes              1     977.5 163901 4934.7
## - wkly_study_hours_..10.hours     1    1271.4 164195 4936.4
## - parent_educ_some.college        1    1278.1 164201 4936.5
## - parent_marital_status_single    1    1329.4 164253 4936.8
## - ethnic_group_D                  1    1436.9 164360 4937.4
## - wkly_study_hours_5.10.hours     1    1580.9 164504 4938.2
## - parent_marital_status_divorced  1    1846.2 164770 4939.7
## - parent_educ_associate.s.degree  1    1914.7 164838 4940.1
## - parent_educ_bachelor.s.degree   1    2271.4 165195 4942.2
## - parent_educ_master.s.degree     1    2399.8 165323 4942.9
## - ethnic_group_E                  1    4381.2 167305 4954.2
## - gender_male                     1    5675.7 168599 4961.5
## - test_prep_completed             1    6373.3 169297 4965.4
## - lunch_type_free.reduced         1   26351.9 189275 5071.2
## 
## Step:  AIC=4929.05
## math_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     nr_siblings_3 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_3                   1       2.6 162926 4927.1
## - parent_marital_status_widowed   1       4.0 162928 4927.1
## - parent_educ_high.school         1      28.3 162952 4927.2
## - ethnic_group_C                  1      60.2 162984 4927.4
## - transport_means_private         1      86.2 163010 4927.6
## - ethnic_group_B                  1      86.8 163010 4927.6
## - nr_siblings_2                   1     122.0 163046 4927.8
## - nr_siblings_1                   1     231.3 163155 4928.4
## <none>                                        162924 4929.1
## - practice_sport_sometimes        1     433.0 163357 4929.6
## - practice_sport_regularly        1     916.0 163840 4932.4
## - is_first_child_yes              1    1024.4 163948 4933.0
## - wkly_study_hours_..10.hours     1    1277.0 164201 4934.5
## - parent_educ_some.college        1    1280.2 164204 4934.5
## - parent_marital_status_single    1    1330.6 164254 4934.8
## - ethnic_group_D                  1    1440.0 164364 4935.4
## - wkly_study_hours_5.10.hours     1    1583.1 164507 4936.2
## - parent_marital_status_divorced  1    1846.1 164770 4937.7
## - parent_educ_associate.s.degree  1    1916.6 164840 4938.1
## - parent_educ_bachelor.s.degree   1    2271.5 165195 4940.2
## - parent_educ_master.s.degree     1    2402.9 165327 4940.9
## - ethnic_group_E                  1    4386.6 167310 4952.2
## - gender_male                     1    5713.1 168637 4959.7
## - test_prep_completed             1    6373.2 169297 4963.4
## - lunch_type_free.reduced         1   26390.1 189314 5069.4
## 
## Step:  AIC=4927.07
## math_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - parent_marital_status_widowed   1       4.0 162930 4925.1
## - parent_educ_high.school         1      28.8 162955 4925.2
## - ethnic_group_C                  1      60.8 162987 4925.4
## - transport_means_private         1      86.1 163012 4925.6
## - ethnic_group_B                  1      88.1 163014 4925.6
## - nr_siblings_2                   1     178.2 163104 4926.1
## - nr_siblings_1                   1     332.3 163258 4927.0
## <none>                                        162926 4927.1
## - practice_sport_sometimes        1     432.5 163359 4927.6
## - practice_sport_regularly        1     915.7 163842 4930.4
## - is_first_child_yes              1    1028.5 163955 4931.0
## - wkly_study_hours_..10.hours     1    1281.8 164208 4932.5
## - parent_educ_some.college        1    1283.4 164210 4932.5
## - parent_marital_status_single    1    1329.3 164255 4932.8
## - ethnic_group_D                  1    1443.8 164370 4933.4
## - wkly_study_hours_5.10.hours     1    1580.6 164507 4934.2
## - parent_marital_status_divorced  1    1843.5 164770 4935.7
## - parent_educ_associate.s.degree  1    1916.5 164843 4936.2
## - parent_educ_bachelor.s.degree   1    2275.5 165202 4938.2
## - parent_educ_master.s.degree     1    2409.5 165336 4939.0
## - ethnic_group_E                  1    4390.0 167316 4950.3
## - gender_male                     1    5712.9 168639 4957.7
## - test_prep_completed             1    6370.7 169297 4961.4
## - lunch_type_free.reduced         1   26387.6 189314 5067.4
## 
## Step:  AIC=4925.09
## math_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - parent_educ_high.school         1      28.5 162959 4923.3
## - ethnic_group_C                  1      62.0 162992 4923.5
## - transport_means_private         1      88.0 163018 4923.6
## - ethnic_group_B                  1      90.8 163021 4923.6
## - nr_siblings_2                   1     180.5 163111 4924.1
## - nr_siblings_1                   1     334.1 163264 4925.0
## <none>                                        162930 4925.1
## - practice_sport_sometimes        1     430.2 163360 4925.6
## - practice_sport_regularly        1     917.9 163848 4928.4
## - is_first_child_yes              1    1030.3 163961 4929.1
## - wkly_study_hours_..10.hours     1    1284.0 164214 4930.5
## - parent_educ_some.college        1    1284.3 164214 4930.5
## - parent_marital_status_single    1    1362.9 164293 4931.0
## - ethnic_group_D                  1    1453.5 164384 4931.5
## - wkly_study_hours_5.10.hours     1    1593.4 164524 4932.3
## - parent_marital_status_divorced  1    1879.0 164809 4934.0
## - parent_educ_associate.s.degree  1    1912.7 164843 4934.2
## - parent_educ_bachelor.s.degree   1    2275.5 165206 4936.2
## - parent_educ_master.s.degree     1    2414.9 165345 4937.0
## - ethnic_group_E                  1    4393.2 167323 4948.3
## - gender_male                     1    5713.7 168644 4955.8
## - test_prep_completed             1    6386.8 169317 4959.5
## - lunch_type_free.reduced         1   26383.6 189314 5065.4
## 
## Step:  AIC=4923.26
## math_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - ethnic_group_C                  1      58.9 163018 4921.6
## - ethnic_group_B                  1      87.6 163046 4921.8
## - transport_means_private         1      93.5 163052 4921.8
## - nr_siblings_2                   1     180.1 163139 4922.3
## - nr_siblings_1                   1     334.9 163294 4923.2
## <none>                                        162959 4923.3
## - practice_sport_sometimes        1     419.0 163378 4923.7
## - practice_sport_regularly        1     901.2 163860 4926.5
## - is_first_child_yes              1    1017.1 163976 4927.2
## - wkly_study_hours_..10.hours     1    1274.6 164233 4928.6
## - parent_marital_status_single    1    1348.3 164307 4929.1
## - ethnic_group_D                  1    1453.8 164413 4929.7
## - wkly_study_hours_5.10.hours     1    1583.4 164542 4930.4
## - parent_marital_status_divorced  1    1875.1 164834 4932.1
## - parent_educ_some.college        1    2108.2 165067 4933.4
## - parent_educ_master.s.degree     1    2978.4 165937 4938.4
## - parent_educ_associate.s.degree  1    3030.4 165989 4938.7
## - parent_educ_bachelor.s.degree   1    3146.8 166106 4939.4
## - ethnic_group_E                  1    4378.6 167337 4946.4
## - gender_male                     1    5690.7 168649 4953.8
## - test_prep_completed             1    6540.7 169499 4958.6
## - lunch_type_free.reduced         1   26390.1 189349 5063.5
## 
## Step:  AIC=4921.6
## math_score ~ gender_male + ethnic_group_B + ethnic_group_D + 
##     ethnic_group_E + parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - ethnic_group_B                  1      30.3 163048 4919.8
## - transport_means_private         1      84.5 163102 4920.1
## - nr_siblings_2                   1     185.5 163203 4920.7
## <none>                                        163018 4921.6
## - nr_siblings_1                   1     344.8 163362 4921.6
## - practice_sport_sometimes        1     423.9 163442 4922.1
## - practice_sport_regularly        1     911.0 163929 4924.9
## - is_first_child_yes              1    1023.3 164041 4925.5
## - wkly_study_hours_..10.hours     1    1246.9 164265 4926.8
## - parent_marital_status_single    1    1356.1 164374 4927.5
## - wkly_study_hours_5.10.hours     1    1559.6 164577 4928.6
## - parent_marital_status_divorced  1    1908.0 164926 4930.6
## - parent_educ_some.college        1    2129.8 165147 4931.9
## - ethnic_group_D                  1    2480.1 165498 4933.9
## - parent_educ_master.s.degree     1    3015.9 166034 4937.0
## - parent_educ_associate.s.degree  1    3109.9 166128 4937.5
## - parent_educ_bachelor.s.degree   1    3174.4 166192 4937.9
## - gender_male                     1    5633.4 168651 4951.8
## - test_prep_completed             1    6545.9 169564 4956.9
## - ethnic_group_E                  1    7027.2 170045 4959.6
## - lunch_type_free.reduced         1   26532.7 189550 5062.6
## 
## Step:  AIC=4919.78
## math_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - transport_means_private         1      89.1 163137 4918.3
## - nr_siblings_2                   1     180.1 163228 4918.8
## - nr_siblings_1                   1     336.1 163384 4919.7
## <none>                                        163048 4919.8
## - practice_sport_sometimes        1     421.4 163469 4920.2
## - practice_sport_regularly        1     915.8 163964 4923.1
## - is_first_child_yes              1    1026.8 164075 4923.7
## - wkly_study_hours_..10.hours     1    1234.6 164283 4924.9
## - parent_marital_status_single    1    1352.8 164401 4925.6
## - wkly_study_hours_5.10.hours     1    1537.7 164586 4926.7
## - parent_marital_status_divorced  1    1915.4 164963 4928.8
## - parent_educ_some.college        1    2112.7 165161 4930.0
## - ethnic_group_D                  1    2615.9 165664 4932.9
## - parent_educ_master.s.degree     1    2995.1 166043 4935.0
## - parent_educ_associate.s.degree  1    3101.6 166150 4935.6
## - parent_educ_bachelor.s.degree   1    3157.7 166206 4936.0
## - gender_male                     1    5629.5 168677 4950.0
## - test_prep_completed             1    6547.1 169595 4955.1
## - ethnic_group_E                  1    7350.4 170398 4959.6
## - lunch_type_free.reduced         1   26522.7 189571 5060.7
## 
## Step:  AIC=4918.3
## math_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + nr_siblings_1 + 
##     nr_siblings_2 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_2                   1     182.2 163319 4917.4
## - nr_siblings_1                   1     329.3 163466 4918.2
## <none>                                        163137 4918.3
## - practice_sport_sometimes        1     431.9 163569 4918.8
## - practice_sport_regularly        1     921.6 164059 4921.6
## - is_first_child_yes              1    1029.5 164167 4922.3
## - wkly_study_hours_..10.hours     1    1240.8 164378 4923.5
## - parent_marital_status_single    1    1382.0 164519 4924.3
## - wkly_study_hours_5.10.hours     1    1545.8 164683 4925.2
## - parent_marital_status_divorced  1    1936.4 165073 4927.5
## - parent_educ_some.college        1    2128.6 165266 4928.6
## - ethnic_group_D                  1    2614.3 165751 4931.4
## - parent_educ_master.s.degree     1    2994.4 166131 4933.5
## - parent_educ_bachelor.s.degree   1    3192.1 166329 4934.7
## - parent_educ_associate.s.degree  1    3212.9 166350 4934.8
## - gender_male                     1    5615.4 168752 4948.4
## - test_prep_completed             1    6513.8 169651 4953.4
## - ethnic_group_E                  1    7372.3 170509 4958.2
## - lunch_type_free.reduced         1   26502.3 189639 5059.0
## 
## Step:  AIC=4917.35
## math_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + nr_siblings_1 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_1                   1     205.5 163525 4916.5
## <none>                                        163319 4917.4
## - practice_sport_sometimes        1     459.5 163779 4918.0
## - practice_sport_regularly        1     933.5 164253 4920.8
## - is_first_child_yes              1    1137.9 164457 4921.9
## - wkly_study_hours_..10.hours     1    1240.5 164560 4922.5
## - parent_marital_status_single    1    1399.3 164718 4923.4
## - wkly_study_hours_5.10.hours     1    1544.0 164863 4924.3
## - parent_marital_status_divorced  1    1912.6 165232 4926.4
## - parent_educ_some.college        1    2120.6 165440 4927.6
## - ethnic_group_D                  1    2631.4 165951 4930.5
## - parent_educ_master.s.degree     1    2919.9 166239 4932.2
## - parent_educ_bachelor.s.degree   1    3206.8 166526 4933.8
## - parent_educ_associate.s.degree  1    3239.1 166558 4934.0
## - gender_male                     1    5633.0 168952 4947.5
## - test_prep_completed             1    6522.2 169841 4952.5
## - ethnic_group_E                  1    7552.9 170872 4958.2
## - lunch_type_free.reduced         1   26680.5 190000 5058.8
## 
## Step:  AIC=4916.55
## math_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## <none>                                        163525 4916.5
## - practice_sport_sometimes        1     488.3 164013 4917.4
## - practice_sport_regularly        1     965.0 164490 4920.1
## - is_first_child_yes              1    1164.6 164689 4921.3
## - wkly_study_hours_..10.hours     1    1246.0 164771 4921.7
## - parent_marital_status_single    1    1396.5 164921 4922.6
## - wkly_study_hours_5.10.hours     1    1540.6 165065 4923.4
## - parent_marital_status_divorced  1    1941.9 165467 4925.7
## - parent_educ_some.college        1    2106.7 165631 4926.7
## - ethnic_group_D                  1    2698.3 166223 4930.1
## - parent_educ_master.s.degree     1    2824.9 166350 4930.8
## - parent_educ_associate.s.degree  1    3197.7 166722 4932.9
## - parent_educ_bachelor.s.degree   1    3215.7 166740 4933.0
## - gender_male                     1    5672.4 169197 4946.9
## - test_prep_completed             1    6538.1 170063 4951.7
## - ethnic_group_E                  1    7669.8 171195 4958.0
## - lunch_type_free.reduced         1   26633.4 190158 5057.6
aic_step_math = AIC(lm_step_math)
bic_step_math = BIC(lm_step_math)
adjr2_step_math = lm_step_math |> broom::glance() |> pull(adj.r.squared)

Reading

lm_step_reading = stepAIC(lm_all_reading, direction = "backward")
## Start:  AIC=4888.54
## reading_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     nr_siblings_3 + nr_siblings_4. + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - parent_marital_status_widowed   1       0.0 155779 4886.5
## - nr_siblings_4.                  1       0.0 155779 4886.5
## - nr_siblings_3                   1       4.5 155784 4886.6
## - ethnic_group_B                  1       4.8 155784 4886.6
## - nr_siblings_1                   1      11.3 155790 4886.6
## - nr_siblings_2                   1      18.7 155798 4886.7
## - practice_sport_regularly        1      30.2 155809 4886.7
## - ethnic_group_C                  1      30.9 155810 4886.7
## - parent_educ_high.school         1      69.9 155849 4887.0
## - practice_sport_sometimes        1      80.2 155859 4887.0
## <none>                                        155779 4888.5
## - transport_means_private         1     350.8 156130 4888.7
## - wkly_study_hours_..10.hours     1     391.3 156171 4888.9
## - parent_educ_some.college        1     647.9 156427 4890.5
## - ethnic_group_D                  1     756.0 156535 4891.1
## - wkly_study_hours_5.10.hours     1     798.5 156578 4891.4
## - is_first_child_yes              1    1137.3 156916 4893.4
## - ethnic_group_E                  1    1198.2 156977 4893.8
## - parent_marital_status_single    1    1350.6 157130 4894.7
## - parent_educ_associate.s.degree  1    1633.6 157413 4896.4
## - parent_marital_status_divorced  1    2019.1 157798 4898.8
## - parent_educ_bachelor.s.degree   1    2083.7 157863 4899.1
## - parent_educ_master.s.degree     1    3406.1 159185 4907.0
## - test_prep_completed             1    9961.7 165741 4945.3
## - lunch_type_free.reduced         1   11987.5 167767 4956.8
## - gender_male                     1   12081.1 167860 4957.4
## 
## Step:  AIC=4886.54
## reading_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + nr_siblings_3 + nr_siblings_4. + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_4.                  1       0.0 155779 4884.5
## - nr_siblings_3                   1       4.4 155784 4884.6
## - ethnic_group_B                  1       4.8 155784 4884.6
## - nr_siblings_1                   1      11.2 155790 4884.6
## - nr_siblings_2                   1      18.7 155798 4884.7
## - practice_sport_regularly        1      30.2 155809 4884.7
## - ethnic_group_C                  1      30.9 155810 4884.7
## - parent_educ_high.school         1      70.0 155849 4885.0
## - practice_sport_sometimes        1      80.3 155860 4885.0
## <none>                                        155779 4886.5
## - transport_means_private         1     351.2 156130 4886.7
## - wkly_study_hours_..10.hours     1     391.3 156171 4886.9
## - parent_educ_some.college        1     647.8 156427 4888.5
## - ethnic_group_D                  1     757.4 156537 4889.1
## - wkly_study_hours_5.10.hours     1     800.1 156579 4889.4
## - is_first_child_yes              1    1137.8 156917 4891.4
## - ethnic_group_E                  1    1198.3 156978 4891.8
## - parent_marital_status_single    1    1367.1 157146 4892.8
## - parent_educ_associate.s.degree  1    1636.3 157416 4894.5
## - parent_marital_status_divorced  1    2037.7 157817 4896.9
## - parent_educ_bachelor.s.degree   1    2083.7 157863 4897.1
## - parent_educ_master.s.degree     1    3407.1 159186 4905.1
## - test_prep_completed             1    9970.2 165749 4943.4
## - lunch_type_free.reduced         1   11989.3 167769 4954.8
## - gender_male                     1   12081.9 167861 4955.4
## 
## Step:  AIC=4884.55
## reading_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + nr_siblings_3 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - ethnic_group_B                  1       4.8 155784 4882.6
## - nr_siblings_3                   1       6.7 155786 4882.6
## - nr_siblings_1                   1      18.6 155798 4882.7
## - practice_sport_regularly        1      30.1 155809 4882.7
## - ethnic_group_C                  1      30.8 155810 4882.7
## - nr_siblings_2                   1      34.4 155814 4882.8
## - parent_educ_high.school         1      70.0 155849 4883.0
## - practice_sport_sometimes        1      80.3 155860 4883.0
## <none>                                        155779 4884.5
## - transport_means_private         1     351.7 156131 4884.7
## - wkly_study_hours_..10.hours     1     394.4 156174 4884.9
## - parent_educ_some.college        1     650.3 156430 4886.5
## - ethnic_group_D                  1     757.9 156537 4887.1
## - wkly_study_hours_5.10.hours     1     802.8 156582 4887.4
## - is_first_child_yes              1    1182.7 156962 4889.7
## - ethnic_group_E                  1    1198.9 156978 4889.8
## - parent_marital_status_single    1    1367.2 157146 4890.8
## - parent_educ_associate.s.degree  1    1639.6 157419 4892.5
## - parent_marital_status_divorced  1    2038.3 157818 4894.9
## - parent_educ_bachelor.s.degree   1    2083.7 157863 4895.1
## - parent_educ_master.s.degree     1    3415.8 159195 4903.1
## - test_prep_completed             1    9971.6 165751 4941.4
## - lunch_type_free.reduced         1   12003.6 167783 4952.9
## - gender_male                     1   12153.7 167933 4953.8
## 
## Step:  AIC=4882.57
## reading_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     nr_siblings_3 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_3                   1       7.2 155791 4880.6
## - nr_siblings_1                   1      19.1 155803 4880.7
## - practice_sport_regularly        1      30.7 155815 4880.8
## - ethnic_group_C                  1      33.4 155817 4880.8
## - nr_siblings_2                   1      33.8 155818 4880.8
## - parent_educ_high.school         1      68.9 155853 4881.0
## - practice_sport_sometimes        1      80.4 155864 4881.1
## <none>                                        155784 4882.6
## - transport_means_private         1     350.5 156135 4882.7
## - wkly_study_hours_..10.hours     1     390.2 156174 4882.9
## - parent_educ_some.college        1     651.6 156436 4884.5
## - wkly_study_hours_5.10.hours     1     798.0 156582 4885.4
## - is_first_child_yes              1    1186.1 156970 4887.8
## - ethnic_group_D                  1    1364.1 157148 4888.8
## - parent_marital_status_single    1    1367.7 157152 4888.9
## - parent_educ_associate.s.degree  1    1654.1 157438 4890.6
## - ethnic_group_E                  1    1871.7 157656 4891.9
## - parent_marital_status_divorced  1    2050.5 157835 4893.0
## - parent_educ_bachelor.s.degree   1    2086.6 157871 4893.2
## - parent_educ_master.s.degree     1    3418.3 159202 4901.2
## - test_prep_completed             1    9975.6 165760 4939.4
## - lunch_type_free.reduced         1   12023.7 167808 4951.1
## - gender_male                     1   12236.3 168020 4952.3
## 
## Step:  AIC=4880.62
## reading_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_1                   1      12.4 155804 4878.7
## - practice_sport_regularly        1      30.6 155822 4878.8
## - ethnic_group_C                  1      33.1 155824 4878.8
## - nr_siblings_2                   1      63.9 155855 4879.0
## - parent_educ_high.school         1      70.1 155861 4879.0
## - practice_sport_sometimes        1      80.0 155871 4879.1
## <none>                                        155791 4880.6
## - transport_means_private         1     350.2 156142 4880.7
## - wkly_study_hours_..10.hours     1     393.6 156185 4881.0
## - parent_educ_some.college        1     655.0 156446 4882.6
## - wkly_study_hours_5.10.hours     1     793.8 156585 4883.4
## - is_first_child_yes              1    1182.1 156973 4885.8
## - ethnic_group_D                  1    1363.2 157154 4886.9
## - parent_marital_status_single    1    1365.3 157157 4886.9
## - parent_educ_associate.s.degree  1    1654.3 157446 4888.6
## - ethnic_group_E                  1    1868.5 157660 4889.9
## - parent_marital_status_divorced  1    2045.2 157836 4891.0
## - parent_educ_bachelor.s.degree   1    2092.5 157884 4891.3
## - parent_educ_master.s.degree     1    3430.3 159222 4899.3
## - test_prep_completed             1    9969.5 165761 4937.4
## - lunch_type_free.reduced         1   12018.7 167810 4949.1
## - gender_male                     1   12287.4 168079 4950.6
## 
## Step:  AIC=4878.69
## reading_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - practice_sport_regularly        1      29.2 155833 4876.9
## - ethnic_group_C                  1      30.9 155835 4876.9
## - parent_educ_high.school         1      69.8 155873 4877.1
## - practice_sport_sometimes        1      76.7 155880 4877.2
## - nr_siblings_2                   1      97.1 155901 4877.3
## <none>                                        155804 4878.7
## - transport_means_private         1     352.5 156156 4878.8
## - wkly_study_hours_..10.hours     1     392.8 156196 4879.1
## - parent_educ_some.college        1     657.8 156461 4880.7
## - wkly_study_hours_5.10.hours     1     794.6 156598 4881.5
## - is_first_child_yes              1    1171.6 156975 4883.8
## - ethnic_group_D                  1    1352.0 157156 4884.9
## - parent_marital_status_single    1    1364.4 157168 4885.0
## - parent_educ_associate.s.degree  1    1660.8 157464 4886.7
## - ethnic_group_E                  1    1856.2 157660 4887.9
## - parent_marital_status_divorced  1    2041.4 157845 4889.0
## - parent_educ_bachelor.s.degree   1    2091.3 157895 4889.3
## - parent_educ_master.s.degree     1    3491.2 159295 4897.7
## - test_prep_completed             1    9965.3 165769 4935.5
## - lunch_type_free.reduced         1   12018.9 167823 4947.1
## - gender_male                     1   12311.0 168115 4948.8
## 
## Step:  AIC=4876.87
## reading_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     practice_sport_sometimes + is_first_child_yes + transport_means_private + 
##     nr_siblings_2 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - ethnic_group_C                  1      31.2 155864 4875.1
## - practice_sport_sometimes        1      52.9 155886 4875.2
## - parent_educ_high.school         1      64.4 155897 4875.3
## - nr_siblings_2                   1      97.1 155930 4875.5
## <none>                                        155833 4876.9
## - transport_means_private         1     355.2 156188 4877.0
## - wkly_study_hours_..10.hours     1     397.8 156231 4877.3
## - parent_educ_some.college        1     668.5 156501 4878.9
## - wkly_study_hours_5.10.hours     1     795.7 156629 4879.7
## - is_first_child_yes              1    1159.4 156992 4881.9
## - parent_marital_status_single    1    1351.9 157185 4883.1
## - ethnic_group_D                  1    1356.1 157189 4883.1
## - parent_educ_associate.s.degree  1    1670.6 157503 4885.0
## - ethnic_group_E                  1    1842.5 157675 4886.0
## - parent_marital_status_divorced  1    2058.1 157891 4887.3
## - parent_educ_bachelor.s.degree   1    2101.2 157934 4887.6
## - parent_educ_master.s.degree     1    3465.9 159299 4895.7
## - test_prep_completed             1    9994.2 165827 4933.8
## - lunch_type_free.reduced         1   11989.7 167823 4945.1
## - gender_male                     1   12320.8 168154 4947.0
## 
## Step:  AIC=4875.06
## reading_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_high.school + parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     is_first_child_yes + transport_means_private + nr_siblings_2 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - practice_sport_sometimes        1      55.2 155919 4873.4
## - parent_educ_high.school         1      62.7 155927 4873.4
## - nr_siblings_2                   1     100.2 155964 4873.7
## <none>                                        155864 4875.1
## - transport_means_private         1     341.4 156205 4875.1
## - wkly_study_hours_..10.hours     1     394.7 156259 4875.5
## - parent_educ_some.college        1     685.3 156549 4877.2
## - wkly_study_hours_5.10.hours     1     801.4 156665 4877.9
## - is_first_child_yes              1    1160.8 157025 4880.1
## - parent_marital_status_single    1    1358.1 157222 4881.3
## - ethnic_group_D                  1    1548.1 157412 4882.4
## - parent_educ_associate.s.degree  1    1705.4 157569 4883.4
## - ethnic_group_E                  1    1995.6 157860 4885.1
## - parent_marital_status_divorced  1    2069.3 157933 4885.6
## - parent_educ_bachelor.s.degree   1    2130.9 157995 4885.9
## - parent_educ_master.s.degree     1    3515.6 159380 4894.2
## - test_prep_completed             1    9999.2 165863 4932.0
## - lunch_type_free.reduced         1   12040.8 167905 4943.6
## - gender_male                     1   12425.5 168290 4945.8
## 
## Step:  AIC=4873.4
## reading_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_high.school + parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + is_first_child_yes + transport_means_private + 
##     nr_siblings_2 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - parent_educ_high.school         1      61.3 155981 4871.8
## - nr_siblings_2                   1     106.9 156026 4872.0
## <none>                                        155919 4873.4
## - transport_means_private         1     349.7 156269 4873.5
## - wkly_study_hours_..10.hours     1     404.0 156323 4873.8
## - parent_educ_some.college        1     679.3 156599 4875.5
## - wkly_study_hours_5.10.hours     1     808.4 156728 4876.3
## - is_first_child_yes              1    1148.7 157068 4878.4
## - parent_marital_status_single    1    1366.3 157286 4879.7
## - ethnic_group_D                  1    1553.6 157473 4880.8
## - parent_educ_associate.s.degree  1    1693.5 157613 4881.6
## - ethnic_group_E                  1    1964.6 157884 4883.3
## - parent_marital_status_divorced  1    2067.3 157987 4883.9
## - parent_educ_bachelor.s.degree   1    2152.0 158071 4884.4
## - parent_educ_master.s.degree     1    3556.7 159476 4892.8
## - test_prep_completed             1   10006.5 165926 4930.4
## - lunch_type_free.reduced         1   12034.2 167954 4941.9
## - gender_male                     1   12438.8 168358 4944.2
## 
## Step:  AIC=4871.77
## reading_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + is_first_child_yes + transport_means_private + 
##     nr_siblings_2 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_2                   1     106.0 156087 4870.4
## <none>                                        155981 4871.8
## - transport_means_private         1     366.3 156347 4872.0
## - wkly_study_hours_..10.hours     1     395.9 156376 4872.2
## - wkly_study_hours_5.10.hours     1     798.1 156779 4874.6
## - is_first_child_yes              1    1128.3 157109 4876.6
## - parent_educ_some.college        1    1287.4 157268 4877.6
## - parent_marital_status_single    1    1344.3 157325 4877.9
## - ethnic_group_D                  1    1589.1 157570 4879.4
## - ethnic_group_E                  1    1970.3 157951 4881.7
## - parent_marital_status_divorced  1    2058.7 158039 4882.2
## - parent_educ_associate.s.degree  1    2866.3 158847 4887.0
## - parent_educ_bachelor.s.degree   1    3118.9 159099 4888.5
## - parent_educ_master.s.degree     1    4479.0 160460 4896.6
## - test_prep_completed             1   10265.9 166246 4930.2
## - lunch_type_free.reduced         1   12043.9 168024 4940.3
## - gender_male                     1   12517.1 168498 4942.9
## 
## Step:  AIC=4870.41
## reading_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + is_first_child_yes + transport_means_private + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## <none>                                        156087 4870.4
## - transport_means_private         1     373.4 156460 4870.7
## - wkly_study_hours_..10.hours     1     395.5 156482 4870.8
## - wkly_study_hours_5.10.hours     1     798.1 156885 4873.2
## - is_first_child_yes              1    1201.8 157288 4875.7
## - parent_educ_some.college        1    1284.6 157371 4876.2
## - parent_marital_status_single    1    1357.2 157444 4876.6
## - ethnic_group_D                  1    1586.7 157673 4878.0
## - ethnic_group_E                  1    2013.8 158100 4880.6
## - parent_marital_status_divorced  1    2034.3 158121 4880.7
## - parent_educ_associate.s.degree  1    2892.1 158979 4885.8
## - parent_educ_bachelor.s.degree   1    3127.8 159214 4887.2
## - parent_educ_master.s.degree     1    4444.5 160531 4895.0
## - test_prep_completed             1   10269.5 166356 4928.8
## - lunch_type_free.reduced         1   12138.7 168225 4939.4
## - gender_male                     1   12513.2 168600 4941.5
aic_step_reading = AIC(lm_step_reading)
bic_step_reading = BIC(lm_step_reading)
adjr2_step_reading = lm_step_reading |> broom::glance() |> pull(adj.r.squared)

Writing

lm_step_writing = stepAIC(lm_all_writing, direction = "backward")
## Start:  AIC=4835.37
## writing_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     nr_siblings_3 + nr_siblings_4. + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_4.                  1       0.1 147282 4833.4
## - nr_siblings_3                   1       0.5 147282 4833.4
## - ethnic_group_B                  1       1.7 147283 4833.4
## - parent_marital_status_widowed   1      20.1 147302 4833.5
## - nr_siblings_1                   1      26.0 147308 4833.5
## - parent_educ_high.school         1      28.6 147310 4833.6
## - ethnic_group_C                  1      40.9 147323 4833.6
## - nr_siblings_2                   1      90.9 147373 4834.0
## - transport_means_private         1     266.3 147548 4835.1
## <none>                                        147282 4835.4
## - wkly_study_hours_..10.hours     1     375.8 147657 4835.8
## - practice_sport_sometimes        1     430.0 147712 4836.1
## - practice_sport_regularly        1     705.2 147987 4837.9
## - wkly_study_hours_5.10.hours     1     795.2 148077 4838.5
## - is_first_child_yes              1     813.1 148095 4838.6
## - ethnic_group_E                  1    1003.3 148285 4839.8
## - parent_marital_status_single    1    1649.8 148932 4843.9
## - parent_educ_some.college        1    1683.7 148965 4844.1
## - ethnic_group_D                  1    1808.8 149091 4844.9
## - parent_marital_status_divorced  1    2114.6 149396 4846.9
## - parent_educ_associate.s.degree  1    2664.0 149946 4850.4
## - parent_educ_bachelor.s.degree   1    4128.2 151410 4859.6
## - parent_educ_master.s.degree     1    5745.6 153027 4869.6
## - lunch_type_free.reduced         1   14934.9 162217 4924.9
## - test_prep_completed             1   19121.0 166403 4949.1
## - gender_male                     1   19504.1 166786 4951.3
## 
## Step:  AIC=4833.37
## writing_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     nr_siblings_3 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_3                   1       1.3 147283 4831.4
## - ethnic_group_B                  1       1.8 147284 4831.4
## - parent_marital_status_widowed   1      20.3 147302 4831.5
## - parent_educ_high.school         1      28.9 147311 4831.6
## - ethnic_group_C                  1      41.0 147323 4831.6
## - nr_siblings_1                   1      43.5 147325 4831.6
## - nr_siblings_2                   1     152.7 147435 4832.4
## - transport_means_private         1     266.3 147548 4833.1
## <none>                                        147282 4833.4
## - wkly_study_hours_..10.hours     1     377.4 147659 4833.8
## - practice_sport_sometimes        1     430.7 147712 4834.1
## - practice_sport_regularly        1     706.8 147989 4835.9
## - wkly_study_hours_5.10.hours     1     796.5 148078 4836.5
## - is_first_child_yes              1     850.5 148132 4836.8
## - ethnic_group_E                  1    1004.7 148286 4837.8
## - parent_marital_status_single    1    1651.0 148933 4841.9
## - parent_educ_some.college        1    1687.6 148969 4842.2
## - ethnic_group_D                  1    1812.0 149094 4843.0
## - parent_marital_status_divorced  1    2114.6 149396 4844.9
## - parent_educ_associate.s.degree  1    2667.7 149950 4848.4
## - parent_educ_bachelor.s.degree   1    4128.3 151410 4857.6
## - parent_educ_master.s.degree     1    5756.1 153038 4867.7
## - lunch_type_free.reduced         1   14955.9 162238 4923.1
## - test_prep_completed             1   19121.7 166403 4947.1
## - gender_male                     1   19610.7 166892 4949.9
## 
## Step:  AIC=4831.38
## writing_score ~ gender_male + ethnic_group_B + ethnic_group_C + 
##     ethnic_group_D + ethnic_group_E + parent_educ_high.school + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + parent_marital_status_widowed + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - ethnic_group_B                  1       1.9 147285 4829.4
## - parent_marital_status_widowed   1      20.3 147303 4829.5
## - parent_educ_high.school         1      29.2 147312 4829.6
## - ethnic_group_C                  1      41.3 147324 4829.6
## - nr_siblings_1                   1      66.5 147350 4829.8
## - nr_siblings_2                   1     212.9 147496 4830.7
## - transport_means_private         1     266.2 147549 4831.1
## <none>                                        147283 4831.4
## - wkly_study_hours_..10.hours     1     379.1 147662 4831.8
## - practice_sport_sometimes        1     430.4 147714 4832.1
## - practice_sport_regularly        1     706.6 147990 4833.9
## - wkly_study_hours_5.10.hours     1     795.2 148078 4834.5
## - is_first_child_yes              1     856.3 148139 4834.9
## - ethnic_group_E                  1    1005.7 148289 4835.8
## - parent_marital_status_single    1    1650.0 148933 4839.9
## - parent_educ_some.college        1    1690.5 148974 4840.2
## - ethnic_group_D                  1    1815.4 149099 4841.0
## - parent_marital_status_divorced  1    2113.3 149396 4842.9
## - parent_educ_associate.s.degree  1    2667.6 149951 4846.4
## - parent_educ_bachelor.s.degree   1    4132.9 151416 4855.6
## - parent_educ_master.s.degree     1    5765.9 153049 4865.8
## - lunch_type_free.reduced         1   14954.7 162238 4921.1
## - test_prep_completed             1   19121.7 166405 4945.1
## - gender_male                     1   19659.2 166942 4948.2
## 
## Step:  AIC=4829.39
## writing_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     parent_marital_status_widowed + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - parent_marital_status_widowed   1      19.6 147305 4827.5
## - parent_educ_high.school         1      28.8 147314 4827.6
## - ethnic_group_C                  1      62.9 147348 4827.8
## - nr_siblings_1                   1      66.3 147351 4827.8
## - nr_siblings_2                   1     212.5 147498 4828.8
## - transport_means_private         1     265.5 147551 4829.1
## <none>                                        147285 4829.4
## - wkly_study_hours_..10.hours     1     377.2 147662 4829.8
## - practice_sport_sometimes        1     430.6 147716 4830.2
## - practice_sport_regularly        1     708.4 147993 4831.9
## - wkly_study_hours_5.10.hours     1     794.2 148079 4832.5
## - is_first_child_yes              1     857.5 148143 4832.9
## - ethnic_group_E                  1    1610.2 148895 4837.7
## - parent_marital_status_single    1    1649.6 148935 4837.9
## - parent_educ_some.college        1    1692.0 148977 4838.2
## - parent_marital_status_divorced  1    2120.3 149405 4840.9
## - parent_educ_associate.s.degree  1    2684.1 149969 4844.5
## - ethnic_group_D                  1    3509.9 150795 4849.7
## - parent_educ_bachelor.s.degree   1    4136.0 151421 4853.6
## - parent_educ_master.s.degree     1    5768.0 153053 4863.8
## - lunch_type_free.reduced         1   14973.4 162258 4919.2
## - test_prep_completed             1   19124.2 166409 4943.1
## - gender_male                     1   19772.2 167057 4946.8
## 
## Step:  AIC=4827.52
## writing_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_high.school + parent_educ_some.college + 
##     parent_educ_associate.s.degree + parent_educ_bachelor.s.degree + 
##     parent_educ_master.s.degree + lunch_type_free.reduced + test_prep_completed + 
##     parent_marital_status_divorced + parent_marital_status_single + 
##     practice_sport_sometimes + practice_sport_regularly + is_first_child_yes + 
##     transport_means_private + nr_siblings_1 + nr_siblings_2 + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - parent_educ_high.school         1      29.6 147334 4825.7
## - ethnic_group_C                  1      63.9 147369 4825.9
## - nr_siblings_1                   1      64.8 147369 4825.9
## - nr_siblings_2                   1     208.0 147513 4826.9
## - transport_means_private         1     259.6 147564 4827.2
## <none>                                        147305 4827.5
## - wkly_study_hours_..10.hours     1     375.7 147680 4827.9
## - practice_sport_sometimes        1     437.0 147742 4828.3
## - practice_sport_regularly        1     704.5 148009 4830.0
## - wkly_study_hours_5.10.hours     1     784.2 148089 4830.5
## - is_first_child_yes              1     854.1 148159 4831.0
## - ethnic_group_E                  1    1626.7 148931 4835.9
## - parent_marital_status_single    1    1630.0 148935 4835.9
## - parent_educ_some.college        1    1689.7 148994 4836.3
## - parent_marital_status_divorced  1    2100.7 149405 4838.9
## - parent_educ_associate.s.degree  1    2701.2 150006 4842.7
## - ethnic_group_D                  1    3510.1 150815 4847.8
## - parent_educ_bachelor.s.degree   1    4135.6 151440 4851.8
## - parent_educ_master.s.degree     1    5755.8 153060 4861.9
## - lunch_type_free.reduced         1   14988.4 162293 4917.4
## - test_prep_completed             1   19104.6 166409 4941.1
## - gender_male                     1   19769.9 167075 4944.9
## 
## Step:  AIC=4825.71
## writing_score ~ gender_male + ethnic_group_C + ethnic_group_D + 
##     ethnic_group_E + parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - ethnic_group_C                  1      62.2 147396 4824.1
## - nr_siblings_1                   1      65.2 147399 4824.1
## - nr_siblings_2                   1     207.6 147542 4825.0
## - transport_means_private         1     269.5 147604 4825.4
## <none>                                        147334 4825.7
## - wkly_study_hours_..10.hours     1     370.6 147705 4826.1
## - practice_sport_sometimes        1     425.5 147760 4826.4
## - practice_sport_regularly        1     689.0 148023 4828.1
## - wkly_study_hours_5.10.hours     1     777.4 148112 4828.7
## - is_first_child_yes              1     841.5 148176 4829.1
## - parent_marital_status_single    1    1613.8 148948 4834.0
## - ethnic_group_E                  1    1624.8 148959 4834.1
## - parent_marital_status_divorced  1    2095.8 149430 4837.1
## - parent_educ_some.college        1    2727.9 150062 4841.1
## - ethnic_group_D                  1    3535.9 150870 4846.2
## - parent_educ_associate.s.degree  1    4200.6 151535 4850.4
## - parent_educ_bachelor.s.degree   1    5585.0 152919 4859.0
## - parent_educ_master.s.degree     1    6920.2 154254 4867.2
## - lunch_type_free.reduced         1   14992.2 162327 4915.6
## - test_prep_completed             1   19456.0 166790 4941.3
## - gender_male                     1   19854.7 167189 4943.6
## 
## Step:  AIC=4824.11
## writing_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_1 + nr_siblings_2 + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_1                   1      72.8 147469 4822.6
## - nr_siblings_2                   1     218.4 147615 4823.5
## - transport_means_private         1     251.7 147648 4823.7
## <none>                                        147396 4824.1
## - wkly_study_hours_..10.hours     1     366.4 147763 4824.5
## - practice_sport_sometimes        1     431.7 147828 4824.9
## - practice_sport_regularly        1     690.6 148087 4826.5
## - wkly_study_hours_5.10.hours     1     785.6 148182 4827.1
## - is_first_child_yes              1     842.1 148239 4827.5
## - parent_marital_status_single    1    1623.9 149020 4832.5
## - ethnic_group_E                  1    1661.6 149058 4832.7
## - parent_marital_status_divorced  1    2110.7 149507 4835.6
## - parent_educ_some.college        1    2774.8 150171 4839.8
## - ethnic_group_D                  1    4133.8 151530 4848.3
## - parent_educ_associate.s.degree  1    4279.4 151676 4849.2
## - parent_educ_bachelor.s.degree   1    5646.9 153043 4857.7
## - parent_educ_master.s.degree     1    7022.2 154419 4866.2
## - lunch_type_free.reduced         1   15069.3 162466 4914.4
## - test_prep_completed             1   19460.1 166857 4939.7
## - gender_male                     1   20037.5 167434 4942.9
## 
## Step:  AIC=4822.58
## writing_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     nr_siblings_2 + wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - nr_siblings_2                   1     158.5 147628 4821.6
## - transport_means_private         1     246.3 147716 4822.2
## <none>                                        147469 4822.6
## - wkly_study_hours_..10.hours     1     368.1 147837 4822.9
## - practice_sport_sometimes        1     454.3 147924 4823.5
## - practice_sport_regularly        1     708.5 148178 4825.1
## - wkly_study_hours_5.10.hours     1     784.0 148253 4825.6
## - is_first_child_yes              1     876.8 148346 4826.2
## - parent_marital_status_single    1    1626.8 149096 4831.0
## - ethnic_group_E                  1    1711.1 149180 4831.5
## - parent_marital_status_divorced  1    2122.4 149592 4834.1
## - parent_educ_some.college        1    2764.5 150234 4838.2
## - ethnic_group_D                  1    4189.7 151659 4847.1
## - parent_educ_associate.s.degree  1    4261.0 151730 4847.6
## - parent_educ_bachelor.s.degree   1    5658.8 153128 4856.3
## - parent_educ_master.s.degree     1    6951.0 154420 4864.2
## - lunch_type_free.reduced         1   15072.7 162542 4912.8
## - test_prep_completed             1   19478.1 166947 4938.2
## - gender_male                     1   19998.7 167468 4941.1
## 
## Step:  AIC=4821.59
## writing_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + transport_means_private + 
##     wkly_study_hours_..10.hours + wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## - transport_means_private         1     252.9 147881 4821.2
## <none>                                        147628 4821.6
## - wkly_study_hours_..10.hours     1     366.9 147995 4821.9
## - practice_sport_sometimes        1     469.7 148098 4822.6
## - practice_sport_regularly        1     709.3 148337 4824.1
## - wkly_study_hours_5.10.hours     1     783.5 148411 4824.6
## - is_first_child_yes              1     954.5 148582 4825.7
## - parent_marital_status_single    1    1643.5 149271 4830.1
## - ethnic_group_E                  1    1762.6 149390 4830.8
## - parent_marital_status_divorced  1    2091.9 149720 4832.9
## - parent_educ_some.college        1    2760.9 150389 4837.2
## - ethnic_group_D                  1    4184.3 151812 4846.1
## - parent_educ_associate.s.degree  1    4302.0 151930 4846.8
## - parent_educ_bachelor.s.degree   1    5671.4 153299 4855.3
## - parent_educ_master.s.degree     1    6896.1 154524 4862.9
## - lunch_type_free.reduced         1   15201.3 162829 4912.5
## - test_prep_completed             1   19483.7 167112 4937.1
## - gender_male                     1   19991.4 167619 4940.0
## 
## Step:  AIC=4821.22
## writing_score ~ gender_male + ethnic_group_D + ethnic_group_E + 
##     parent_educ_some.college + parent_educ_associate.s.degree + 
##     parent_educ_bachelor.s.degree + parent_educ_master.s.degree + 
##     lunch_type_free.reduced + test_prep_completed + parent_marital_status_divorced + 
##     parent_marital_status_single + practice_sport_sometimes + 
##     practice_sport_regularly + is_first_child_yes + wkly_study_hours_..10.hours + 
##     wkly_study_hours_5.10.hours
## 
##                                  Df Sum of Sq    RSS    AIC
## <none>                                        147881 4821.2
## - wkly_study_hours_..10.hours     1     372.5 148253 4821.6
## - practice_sport_sometimes        1     487.8 148368 4822.3
## - practice_sport_regularly        1     717.3 148598 4823.8
## - wkly_study_hours_5.10.hours     1     793.3 148674 4824.3
## - is_first_child_yes              1     959.0 148840 4825.3
## - parent_marital_status_single    1    1696.8 149578 4830.0
## - ethnic_group_E                  1    1779.3 149660 4830.6
## - parent_marital_status_divorced  1    2127.1 150008 4832.8
## - parent_educ_some.college        1    2791.6 150672 4836.9
## - ethnic_group_D                  1    4179.2 152060 4845.6
## - parent_educ_associate.s.degree  1    4512.6 152393 4847.7
## - parent_educ_bachelor.s.degree   1    5747.7 153628 4855.4
## - parent_educ_master.s.degree     1    6897.6 154778 4862.4
## - lunch_type_free.reduced         1   15176.2 163057 4911.8
## - test_prep_completed             1   19386.8 167267 4936.0
## - gender_male                     1   20042.2 167923 4939.7
aic_step_writing = AIC(lm_step_writing)
bic_step_writing = BIC(lm_step_writing)
adjr2_step_writing = lm_step_writing |> broom::glance() |> pull(adj.r.squared)

Readable Tables of Results

Math

model_stats_math = tibble(
  math_model_type = c("All", "Backward Selection", "Economic", "Hard Worker", "Demographic", "Family Structure"),
  ADJ_R2 = c(adjr2_all_math,
             adjr2_step_math,
             adjr2_econ_math, 
             adjr2_hw_math,
             adjr2_demo_math,
             adjr2_fam_math),
  AIC = c(aic_all_math,
          aic_step_math,
          aic_econ_math,
          aic_hw_math,
          aic_demo_math,
          aic_fam_math),
  BIC = c(bic_all_math,
          bic_step_math,
          bic_econ_math,
          bic_hw_math,
          bic_demo_math,
          bic_fam_math)
)

model_stats_math |> knitr::kable()
math_model_type ADJ_R2 AIC BIC
All 0.2673613 7623.361 7754.429
Backward Selection 0.271766 7608.853 7696.231
Economic 0.1853197 7707.305 7755.848
Hard Worker 0.01053602 7887.595 7916.721
Demographic 0.07677012 7822.907 7856.887
Family Structure 0.01569303 7886.611 7935.155

Reading

model_stats_reading = tibble(
  reading_model_type = c("All", "Backward Selection", "Economic", "Hard Worker", "Demographic", "Family Structure"),
  ADJ_R2 = c(adjr2_all_reading, 
             adjr2_step_reading,
             adjr2_econ_reading, 
             adjr2_hw_reading,
             adjr2_demo_reading,
             adjr2_fam_reading),
  AIC = c(aic_all_reading,
          aic_step_reading,
          aic_econ_reading,
          aic_hw_reading,
          aic_demo_reading,
          aic_fam_reading),
  BIC = c(bic_all_reading,
          bic_step_reading,
          bic_econ_reading,
          bic_hw_reading,
          bic_demo_reading,
          bic_fam_reading)
)

model_stats_reading |> knitr::kable()
reading_model_type ADJ_R2 AIC BIC
All 0.2286039 7580.852 7711.920
Backward Selection 0.2353751 7562.721 7645.245
Economic 0.1474199 7659.034 7707.578
Hard Worker 0.002965035 7803.444 7832.570
Demographic 0.07241858 7735.987 7769.968
Family Structure 0.01454485 7796.339 7844.883

Writing

model_stats_writing = tibble(
  writing_model_type = c("All", "Backward Selection", "Economic", "Hard Worker", "Demographic", "Family Structure"),
  ADJ_R2 = c(adjr2_all_writing, 
             adjr2_step_writing,
             adjr2_econ_writing, 
             adjr2_hw_writing,
             adjr2_demo_writing,
             adjr2_fam_writing),
  AIC = c(aic_all_writing,
          aic_step_writing,
          aic_econ_writing,
          aic_hw_writing,
          aic_demo_writing,
          aic_fam_writing),
  BIC = c(bic_all_writing,
          bic_step_writing,
          bic_econ_writing,
          bic_hw_writing,
          bic_demo_writing,
          bic_fam_writing)
)

model_stats_writing |> knitr::kable()
writing_model_type ADJ_R2 AIC BIC
All 0.3275407 7527.677 7658.744
Backward Selection 0.3313331 7513.524 7600.902
Economic 0.2084674 7665.549 7714.092
Hard Worker 0.003411755 7879.966 7909.092
Demographic 0.1072178 7776.685 7810.666
Family Structure 0.01292108 7874.847 7923.391

Final model statistics

t1 <- broom::tidy(lm_step_math) |> dplyr::select(-std.error)

t2 <- broom::tidy(lm_step_reading) |> dplyr::select(-std.error)

t3 <- broom::tidy(lm_step_writing) |> dplyr::select(-std.error)

Model Diagnostics

Plotting the residuals against the fitted values, we see no significant relationship.

plot(predict(lm_all_math, score_dummies), lm_all_math$residuals)

Examining the residuals for normality, we see some deviation, but not egregious deviation.

qqnorm(lm_all_math$residuals)

Examining the residuals versus leverage, we find that no point is exerting fully undue leverage.

plot(lm_all_math, which = 5)